package com.cictec.middleware.elasticsearch.camel;

import java.util.Date;
import java.util.Map;

import org.apache.camel.CamelContext;
import org.apache.camel.ProducerTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.alibaba.fastjson.JSON;
import com.cictec.middleware.commons.spring.SpringContextHolder;
import com.cictec.middleware.commons.utils.DateUtils;
import com.cictec.middleware.commons.utils.PMSUtils;
import com.cictec.middleware.commons.utils.PropertiesUtils;
import com.cictec.middleware.commons.utils.elasticsearch.ESModel;

/**
 * GPS位置信息activeMq接入方式入口服务
 * @author ql
 */
@Component
public class MiddlewareESCamelServer{

	public static Logger logger = LoggerFactory.getLogger(MiddlewareESCamelServer.class);

//	@Produce(uri = "seda:middle.real.caculate.save.es")
//	private ProducerTemplate realCaculateProducerTemplate;
//
//	@Produce(uri = "seda:middle.mileage.caculate.save.es")
//	private ProducerTemplate busMileageProducerTemplate;
	
	@Autowired
	private ProducerTemplate realCaculateProducerTemplate;
	@Autowired
	private ProducerTemplate busMileageProducerTemplate;
	
	public CamelContext camelContext;

	/**
	 * 保存实时计算中的进出站信息
	 * @param map	进出站数据
	 */
	public void saveRealCaculateEnterOutStation(Map map) {

		// 这里通过camel的seda创建线程 异步处理信息，也可以直接调用ESPositionService里的方法
		realCaculateProducerTemplate.sendBody(map);
	}
	
	/**
	 * 里程计算信息
	 * @param list
	 */
	public void saveMileageCaculate(Map map) {
		/*
		 * {
		 *  "realCaculate" : "busMileage",
		 *  "date" : "日期",
		 *  "busUuid" : "busUuid",
		 *  "busNumber" : "busNumber",
		 *  "saveEnterOut" : "进出站信息json",
		 *  "savePosition" : "位置信息json",
		 * }
		 */
		busMileageProducerTemplate.sendBody(map);
	}
	
}
